home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-08-10 | 9.7 KB | 347 lines | [TEXT/MPS ] |
- (*
- File: WorldScript.mod
-
- Contains: WorldScript I Interfaces.
-
- Version: Technology: System 7.5
- Package: Universal Interfaces 2.0 in “MPW Latest” on ETO #17
-
- Copyright: © 1984-1995 by Apple Computer, Inc.
- All rights reserved.
-
- Bugs?: If you find a problem with this file, use the Apple Bug Reporter
- stack. Include the file and version information (from above)
- in the problem description and send to:
- Internet: apple.bugs.applelink.apple.com
- AppleLink: APPLE.BUGS
-
- *)
-
- (*$TAGS-*)
- (*$CALLING PASCAL*)
- MODULE WorldScript;
-
- IMPORT SYSTEM, Types, QuickdrawText;
-
- (* $PUSH*)
- (* $ALIGN MAC68K*)
- (* $LibExport+*)
-
- CONST
- kVariableLengthArray* = 1;
-
-
- TYPE
- WSIOffset* = Types.UInt16;
-
- WSIByteCount* = Types.UInt8;
-
- WSIByteIndex* = Types.UInt8;
-
- (* offset from start of sub-table to row in state table *)
- WSIStateOffset* = Types.UInt16;
-
- WSITableOffset* = Types.UInt32;
-
- WSISubtableOffset* = Types.UInt16;
-
- WSIGlyphcode* = Types.UInt16;
-
- WSITableIdentifiers* = Types.UInt32;
-
-
- CONST
- kScriptSettingsTag* = LONG("info");
- kMetamorphosisTag* = LONG("mort");
- kGlyphExpansionTag* = LONG("g2g#");
- kPropertiesTag* = LONG("prop");
- kJustificationTag* = LONG("kash");
- kCharToGlyphTag* = LONG("cmap");
- kGlyphToCharTag* = LONG("pamc");
- kFindScriptRunTag* = LONG("fstb");
-
- (**** L O O K U P T A B L E T Y P E S ****)
- WSILookupSimpleArray* = 0; (* a simple array indexed by glyph code *)
- WSILookupSegmentSingle* = 2; (* segment mapping to single value *)
- WSILookupSegmentArray* = 4; (* segment mapping to lookup array *)
- WSILookupSingleTable* = 6; (* sorted list of glyph, value pairs *)
- WSILookupTrimmedArray* = 8; (* a simple trimmed array indexed by glyph code *)
-
-
- TYPE
- WSILookupTableFormat* = INTEGER;
-
- WSILookupValue* = INTEGER;
-
- (* An offset from the beginning of the lookup table *)
- WSILookupOffset* = INTEGER;
-
- (* FORMAT SPECIFIC DEFINITIONS *)
- (* The format specific part of the subtable header *)
- WSILookupFormatSpecificHeader* = RECORD
- (*ΔΔCASE INTEGER OF
- 0: (
- lookupArray*: WSILookupArrayHeader;
- );
- 1: (
- trimmedArray*: WSILookupTrimmedArrayHeader;
- );ΔΔ*)
- END;
-
- (*
- lookupSimpleArray*:
-
- This is a simple array which maps all glyphs in the font
- to lookup values.
- *)
- WSILookupArrayHeader* = RECORD(WSILookupFormatSpecificHeader)
- lookupValues*: ARRAY 1 (*ΔΔ[0..0]ΔΔ*) OF WSILookupValue; (* The array of values indexed by glyph code *)
- END;
-
- (*
- lookupTrimmedArray*:
-
- This is a single trimmed array which maps a single range
- of glyhs in the font to lookup values.
- *)
- WSILookupTrimmedArrayHeader* = RECORD(WSILookupFormatSpecificHeader)
- firstGlyph*: WSIGlyphcode;
- limitGlyph*: WSIGlyphcode;
- valueArray*: ARRAY 1 (*ΔΔ[0..0]ΔΔ*) OF WSILookupValue;
- END;
-
- (* The overall subtable header *)
- WSILookupTableHeader* = RECORD
- format*: WSILookupTableFormat; (* table format *)
- fsHeader*: WSILookupFormatSpecificHeader; (* format specific header *)
- END;
-
- (**** G L Y P H E X P A N S I O N ****)
-
- CONST
- (* fixed 1.0 *)
- kCurrentGlyphExpansionVersion* = $00010000;
-
-
- TYPE
- GlyphExpansionFormats* = INTEGER;
-
-
- CONST
- GlyphExpansionLookupFormat* = 1;
- GlyphExpansionContextualFormat* = 2;
-
-
- TYPE
- ExpandedGlyphCluster* = (*ΔΔPACKEDΔΔ*) RECORD
- numGlyphs*: WSIByteCount;
- bestGlyph*: WSIByteIndex;
- glyphs*: ARRAY 1 (*ΔΔ[0..0]ΔΔ*) OF WSIGlyphcode;
- END;
-
- ExpandedGlyphOffset* = RECORD
- glyph*: WSIGlyphcode;
- offset*: WSIOffset; (* offset to ExpandedGlyphCluster *)
- END;
-
- GlyphExpansionStateTable* = RECORD
- stateTableOffset*: WSISubtableOffset;
- classTableOffset*: WSISubtableOffset;
- actionTableOffset*: WSISubtableOffset; (* state, class and actions tables follow here... *)
- END;
-
- GlyphExpansionTable* = RECORD
- version*: Types.Fixed;
- format*: INTEGER;
- expansionNumer*: INTEGER;
- expansionDenom*: INTEGER; (* num/denom ratio for expansion <2> *)
- (*ΔΔCASE INTEGER OF
- 0: (
- stateTable*: GlyphExpansionStateTable;
- );
- 1: (
- lookup*: WSILookupTableHeader; (* expanded glyph clusters follow here... *)
- );ΔΔ*)
- END;
-
- (* Glyph-to-Character constants and types *)
-
- CONST
- kCurrentGlyphToCharVersion* = $00010100;
-
-
- TYPE
- GlyphToCharLookupFormats* = INTEGER;
-
-
- CONST
- kGlyphToCharLookup8Format* = 1;
- kGlyphToCharLookup16Format* = 2;
- kGlyphToCharLookup32Format* = 3;
-
-
- TYPE
- GlyphToCharFontIndex* = Types.UInt8;
-
- QDGlyphcode* = Types.UInt8;
-
- GlyphToCharActionTable* = RECORD
- fontNameOffset*: WSISubtableOffset; (* offset relative to this table *)
- actions*: WSILookupTableHeader; (* only support lookupSimpleArray format for now *)
- END;
-
- GlyphToCharActionHeader* = RECORD
- numTables*: INTEGER; (* 0..n *)
- offsets*: ARRAY 1 (*ΔΔ[0..0]ΔΔ*) OF WSISubtableOffset; (* offsets from start of action table header *)
- END;
-
- GlyphToCharHeader* = RECORD
- version*: Types.Fixed;
- actionOffset*: WSISubtableOffset; (* offset to GlyphToCharActionHeader *)
- format*: INTEGER; (* size of font mask *)
- mappingTable*: WSILookupTableHeader;
- END;
-
- (* JUSTIFICATION TYPES
- WorldScript supports justification of text using insertion. The justification
- table specifies a insertion string to insert between 2 specified glyphs.
- Each combination of inter-glyph boundary can be assigned a justification priority,
- the higher the priority the more justification strings inserted at that position.
-
- The priorities for each inter-glyph boundary are specified by the justification table's
- state table.
-
- Special handling is done for scripts which use spaces to justify, because the width of
- a space varies depending on the setting of SpaceExtra. This is why the number of spaces
- per inserting string is specified in the justification table.
-
- *)
-
- CONST
- (* 1.0 not supported *)
- kCurrentJustificationVersion* = $0200;
-
- kJustificationStateTableFormat* = 1;
-
- (* WSI's internal limitation <12> *)
- kMaxJustificationStringLength* = 13;
-
-
- TYPE
- WSIJustificationPriority* = Types.UInt8;
-
-
- CONST
- WSIJustificationSetMarkMask* = $80;
-
-
- TYPE
- WSIJustificationStateEntry* = (*ΔΔPACKEDΔΔ*) RECORD
- markPriority*: WSIJustificationPriority; (* non-zero priorities means insertion *)
- priority*: WSIJustificationPriority;
- newState*: WSIStateOffset;
- END;
-
- WSIJustificationClasses* = INTEGER;
-
-
- CONST
- wsiJustEndOfLineClass* = 0;
- wsiJustEndOfRunClass* = 1;
- wsiJustDeletedGlyphClass* = 2;
- wsiJustUserDefinedClass* = 3;
-
-
- TYPE
- WSIJustificationStates* = INTEGER;
-
-
- CONST
- wsiStartOfLineState* = 0; (* pre-defined states *)
- wsiStartOfRunState* = 1;
- wsiUserDefinedState* = 2;
-
- (* pre-multiplied: class# * sizeof(WSIJustificationStateEntry) *)
-
- TYPE
- WSIJustificationClassOffset* = Types.UInt8;
-
- WSIJustificationStateTable* = RECORD
- maxPriorities*: INTEGER;
- rowWidth*: INTEGER; (* width of a state table row in bytes *)
- classTableOffset*: INTEGER;
- stateTableOffset*: INTEGER;
- END;
-
- WSIJustificationHeader* = RECORD
- version*: INTEGER;
- format*: INTEGER;
- scaling*: Types.Point; (* numer/denom scaling of priority weights <7> *)
- spacesPerInsertion*: INTEGER; (* # of $20 chars in justification insertion string <12> *)
- justStringOffset*: INTEGER; (* offset to justification string *)
- stateTable*: WSIJustificationStateTable; (* long-aligned boundary aligned w/ spacesPerInsertion field - justification string follows *)
- END;
-
- (* Line Layout's Property table version <11> *)
-
- CONST
- (* v1.0 *)
- currentPropsTableVersion* = $00010000;
-
- (* ??? is this right *)
- kCharToGlyphCurrentVersion* = 0100;
-
- (* pass as priorityWeight to JustifyWSILayout to use script's current just setting *)
- kScriptsDefaultJustWeight* = -1;
-
-
- TYPE
- WSIGlyphInfoRec* = RECORD
- qdChar*: Types.SInt8; (* UInt8 *)
- rightToLeft*: Types.SInt8; (* !0 means rightToLeft, 0 means leftToRight *)
- fontID*: INTEGER;
- originalOffset*: INTEGER; (* or negative original offset if not in original text input *)
- unused*: INTEGER; (* long-align *)
- END;
-
- WSIGlyphInfoRecPtr* = POINTER TO WSIGlyphInfoRec;
- WSIGlyphInfoHandle* = HANDLE TO WSIGlyphInfoRec (*ΔΔPOINTER TO WSIGlyphInfoRecPtrΔΔ*);
-
- WSILayoutHandle* = Types.Handle;
-
-
- PROCEDURE NewWSILayout*(layoutH: WSILayoutHandle; text: Types.Ptr; txLength: INTEGER; lineDirection: INTEGER; flags: LONGINT; VAR err: Types.OSErr): WSILayoutHandle;
- (*$IF NOT GENERATINGCFM*)
- INLINE PASCAL $2F3C, $8414, $0040, $A8B5;
- (*$END*)
- PROCEDURE JustifyWSILayout*(layoutH: WSILayoutHandle; slop: Types.Fixed; priorityWeight: INTEGER; styleRunPosition: QuickdrawText.JustStyleCode; numer: Types.Point; denom: Types.Point; VAR err: Types.OSErr): WSILayoutHandle;
- (*$IF NOT GENERATINGCFM*)
- INLINE PASCAL $2F3C, $8418, $0042, $A8B5;
- (*$END*)
- PROCEDURE MeasureWSILayout*(layoutH: WSILayoutHandle; numer: Types.Point; denom: Types.Point): Types.Fixed;
- (*$IF NOT GENERATINGCFM*)
- INLINE PASCAL $2F3C, $840C, $0044, $A8B5;
- (*$END*)
- PROCEDURE DrawWSILayout*(layoutH: WSILayoutHandle; numer: Types.Point; denom: Types.Point);
- (*$IF NOT GENERATINGCFM*)
- INLINE PASCAL $2F3C, $800C, $0046, $A8B5;
- (*$END*)
- (* "low-level" routines *)
- PROCEDURE GetWSILayoutParts*(layoutH: WSILayoutHandle; destH: WSIGlyphInfoHandle; VAR numGlyphs: INTEGER; VAR err: Types.OSErr): WSIGlyphInfoHandle;
- (*$IF NOT GENERATINGCFM*)
- INLINE PASCAL $2F3C, $8410, $0048, $A8B5;
- (*$END*)
- PROCEDURE DrawWSIGlyphs*(length: INTEGER; qdCodes: Types.Ptr; numer: Types.Point; denom: Types.Point);
- (*$IF NOT GENERATINGCFM*)
- INLINE PASCAL $2F3C, $800E, $004A, $A8B5;
- (*$END*)
- PROCEDURE xMeasureWSIGlyphs*(VAR qdCodes: Types.Ptr; length: INTEGER; numer: Types.Point; denom: Types.Point): Types.Fixed;
- (*$IF NOT GENERATINGCFM*)
- INLINE PASCAL $2F3C, $840E, $004C, $A8B5;
- (*$END*)
-
- (* $ALIGN RESET*)
- (* $POP*)
-
- END WorldScript.
-